using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class LocalizedPropertyMap : EntityTypeConfiguration<LocalizedProperty>
    {
        public LocalizedPropertyMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.LocaleKeyGroup)
                .IsRequired()
                .HasMaxLength(400);

            this.Property(t => t.LocaleKey)
                .IsRequired()
                .HasMaxLength(400);

            this.Property(t => t.LocaleValue)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("LocalizedProperty");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.EntityId).HasColumnName("EntityId");
            this.Property(t => t.LanguageId).HasColumnName("LanguageId");
            this.Property(t => t.LocaleKeyGroup).HasColumnName("LocaleKeyGroup");
            this.Property(t => t.LocaleKey).HasColumnName("LocaleKey");
            this.Property(t => t.LocaleValue).HasColumnName("LocaleValue");

            // Relationships
            this.HasRequired(t => t.Language)
                .WithMany(t => t.LocalizedProperties)
                .HasForeignKey(d => d.LanguageId);

        }
    }
}
